ノードのハンドル
[containers.node_handles]
同時連想コンテナー (concurrent_map、concurrent_multimap、concurrent_set、concurrent_multiset、concurrent_unordered_map、concurrent_unordered_multimap、concurrent_unordered_set、およびd concurrent_unordered_multiset) は、接続されたノードに要素を個別に割り当てて格納します。これらのコンテナーは、データを実際にコピーまたは移動することなく接続を変更することで、互換性のあるノードタイプを持つコンテナー間でのデータ転送をサポートします。
クラスの概要
class node-handle { // Exposition-only name
public:
using key_type = <container-specific>; // Only for maps
using mapped_type = <container-specific>; // Only for maps
using value_type = <container-specific>; // Only for sets
using allocator_type = <container-specific>;
node-handle();
node-handle( node-handle&& other );
~node-handle();
node-handle& operator=( node-handle&& other );
void swap( node-handle& nh );
bool empty() const;
explicit operator bool() const;
key_type& key() const; // Only for maps
mapped_type& mapped() const; // Only for maps
value_type& value() const; // Only for sets
allocator_type get_allocator() const;
};node handle は、コンテナー固有の移動専用のネストされたタイプ (container::node_type として) で、コンテナーのインスタンスの外部ノードを表わします。これにより、ノードに保存されているデータの読み取りと変更、および互換性のあるコンテナー・インスタンスへのノードの挿入が可能になります。次のコンテナーには互換性のあるノードタイプがあるため、ノードを交換できます。
key_type、mapped_typeおよびallocator_typeを持つconcurrent_mapとconcurrent_multimap。value_typeおよびallocator_typeを持つconcurrent_setとconcurrent_multiset。key_type、mapped_typeおよびallocator_typeを持つconcurrent_unordered_mapとconcurrent_unordered_multimap。value_typeおよびallocator_typeを持つconcurrent_unordered_setとconcurrent_unordered_multiset。
デフォルトまたは移動元のノードハンドルは空であり、有効なノードを示していません。空ではないノードハンドルは、通常 unsafe_extract メソッドなどを使用してノードがコンテナーから抽出されるときに作成されます。コンテナーのアロケーターのコピーとノードを保存します。割り当てまたは破棄を行う際に、空でないノードハンドルは格納されたデータを破棄し、ノードの割り当てを解除します。
メンバー関数
コンストラクター
node-handle();空のノードハンドルを構築します。
node-handle( node-handle&& other );
otherからノードの所有権を取得するノードハンドルを構築します。それ以外
otherは空の状態になります。
割り当て
node-handle& operator=( node-handle&& other );ノードの所有権を
otherから*thisに転送します。転送前に*thisが空でない場合、保存されているノードを破棄して割り当てを解除します。
std::allocator_traits<allocator_type>::propagate_on_container_move_assignment::valueがtrueの場合、保存されているアロケーターを移動して割り当てます。
otherは空の状態になります。
デストラクター
~node-handle();ノードのハンドルを破棄します。空でない場合、所有するノードを破棄して割り当てを解除します。
Swap
void swap( node-handle& other )
*thisとotherが所有するノードを交換します。
std::allocator_traits<allocator_type>::propagate_on_container_swap::valueがtrueの場合、格納されているアロケーターをスワップします。
状態
bool empty() const;戻り値: ノードのハンドルが空の場合は
true、それ以外はfalseを返します
explicit operator bool() const;
!empty()と等価です。
ストアされた要素のアクセス
key_type& key() const;ノードハンドルのマップでのみ使用できます。
戻り値: 所有するノードに格納されている要素のキーへの参照を返します。
ノードハンドルが空の場合の動作は未定義です。
mapped_type& mapped() const;ノードハンドルのマップでのみ使用できます。
戻り値: 所有するノードに格納されている要素の値への参照を返します。
ノードハンドルが空の場合の動作は未定義です。
value_type& value() const;ノードハンドルの設定でのみ使用できます。
戻り値: 所有するノードに格納されている要素への参照を返します。
ノードハンドルが空の場合の動作は未定義です。
get_allocator
allocator_type get_allocator() const;戻り値: ノードハンドルに保存されたアロケーターのコピーを返します。
ノードハンドルが空の場合の動作は未定義です。
